package com.dragon.client.controller.auth;

import com.dragon.common.model.ResponseData;
import com.dragon.logical.service.auth.ICalendarService;
import com.dragon.repository.domain.dto.CalendaredDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sy
 * @since 2023-07-19
 */
@RestController
@RequestMapping("calendar")
@Api(tags = "日期管理")
public class CalendarController {

    @Autowired
    ICalendarService service;


    @PostMapping("isWork")
    @ApiOperation(value = "获取日期是否是工作日")
    public ResponseData isWorkDay(@ApiParam(name = "date",readOnly = true,type = "date",value = "日期") @RequestParam String date){
        return ResponseData.success(CalendaredDTO.convert(service.isWorkDay(date)));
    }

    @PostMapping("update")
    @ApiOperation(value = "更新年份数据")
    public ResponseData updateCalendar(@ApiParam(name = "years",required = true,type = "int",value = "年份") @RequestParam Integer years){
        service.calendarUpdate(years);
        return ResponseData.success();
    }




}
